//
//  UrbanBureauViewController.m
//  UrbanManagement
//
//  Created by Can on 18/4/10.
//  Copyright © 2018年 hwd. All rights reserved.
//

#import "UrbanBureauViewController.h"
#import "UrbanBureauTableViewCell.h"

@interface UrbanBureauViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSArray *array;//数据源

@end

@implementation UrbanBureauViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self initTitleWithTitle:_titleStr];

    [self creatTableView];
    
    [self creatData];
}

- (void)creatTableView{
    _tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    _tableView.backgroundColor = Color(247, 247, 247);
    [self.view addSubview:_tableView];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.showsHorizontalScrollIndicator = NO;
    _tableView.showsVerticalScrollIndicator = NO;
    _tableView.separatorStyle = 0;
    _tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
}

- (void)creatData
{
    switch (_UrbanChoseType) {
        case UrbanChoseBureauType://部门
            _array = BureauArr;
            break;
            
        case UrbanChoseCarColorType://车辆颜色
    
            break;
            
        case UrbanChoseCarTypesType://车辆类型
            _array = CarTypes;
            break;
            
        case UrbanChoseNumberPlateColorType://车牌号颜色
            _array = NumberPlateColor;
            break;
            
        default:
            break;
    }
    
    [_tableView reloadData];
}


#pragma mark - tabledelegate

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return _array.count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

//section头部间距
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 1;//section头部高度
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UrbanBureauTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BureauCell"];
    if (!cell) {
        cell = [[UrbanBureauTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"BureauCell"];
    }
    cell.textLabel.text = _array[indexPath.section];
    cell.textLabel.font = [UIFont systemFontOfSize:15*screenW_6];
    return cell;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if (_UrbanBureauViewControllerBlock) {
        _UrbanBureauViewControllerBlock(_array[indexPath.section]);
    }
    
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50*screenW_6;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
